<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
    <head>
        <th:block th:include="include :: header('请假审批详情')"/>
        <th:block th:include="include :: datetimepicker-css"/>
    </head>
    <body class="gray-bg">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form class="form-horizontal" th:object="${leave}" style="margin-top: 20px;">
                        <input type="hidden" name="id" id="leaveId" th:field="*{id}">
                        <div class="form-group col-sm-6 inline">
                            <label class="col-sm-3 control-label">流程类型:</label>
                            <input type="text" class="form-control" style="width: 50%" th:field="*{flowCategoryInfo.name}" disabled/>
                        </div>
                        <div class="form-group col-sm-6 inline">
                            <label class="col-sm-3 control-label">请假天数:</label>
                            <input type="text" class="form-control" style="width: 50%" th:field="*{leaveDays}" disabled/>
                        </div>
                        <div class="form-group col-sm-6 inline">
                            <label class="col-sm-3 control-label">开始时间:</label>
                            <input type="text" class="form-control" style="width: 50%" th:value="${#dates.format(leave.beginDate, 'yyyy-MM-dd')}" disabled/>
                        </div>
                        <div class="form-group col-sm-6 inline">
                            <label class="col-sm-3 control-label">结束时间:</label>
                            <input type="text" class="form-control" style="width: 50%" th:value="${#dates.format(leave.finishDate, 'yyyy-MM-dd')}" disabled/>
                        </div>
                        <div class="form-group col-sm-6 inline">
                            <label class="col-sm-3 control-label">请假原因:</label>
                            <textarea name="reason" class="form-control" style="width: 50%" disabled>[[*{reason}]]</textarea>
                        </div>
                        <div class="form-group col-sm-6 inline">
                            <label class="col-sm-3 control-label">创建时间:</label>
                            <input type="text" class="form-control" style="width: 50%" th:value="${#dates.format(leave.createDate, 'yyyy-MM-dd')}" disabled/>
                        </div>
                        <div class="form-group col-sm-6 inline">
                            <label class="col-sm-3 control-label">请假证明:</label>
                            <a th:if="${leave.picture != null}" th:href="@{${leave.picture}}" target="_blank">
                                <img style="width: 50%;height: 100px;" th:src="@{${leave.picture}}"/>
                            </a>
                            <input th:if="${leave.picture == null}" class="form-control" style="width: 50%;" value="无" disabled/>
                        </div>
                    </form>
                </div>
                <div th:if="${status == '1'}" class="col-sm-12 text-center search-collapse" style="height: 60px;margin-top:10px;">
                    <button class="center btn btn-primary" id="through" style="margin-top: 8px">通过</button>
                    <button class="center btn btn-warning" style="margin-top: 8px" data-toggle="modal" data-target="#reject">驳回</button>
                    <div class="modal inmodal" id="reject" tabindex="-1" role="dialog" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content animated bounceInRight">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                                    </button>
                                    <i class="fa fa-paper-plane modal-icon"></i>
                                    <h4 class="modal-title">驳回原因</h4>
                                    <small class="font-bold">填写您驳回申请的原因</small>
                                </div>
                                <div class="modal-body">
                                    <div class="form-group">
                                        <textarea name="reject" id="textareaReject" rows="3" placeholder="请输入驳回原因" class="form-control" style="resize: none;vertical-align:top;outline:none;"></textarea>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                    <button type="button" class="btn btn-primary" id="rejectSubmit">确定</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <th:block th:include="include :: footer"/>
        <script th:inline="javascript">
            var prefix = ctx + "oa/leaveCheck";

            console.log([[${leave}]])

            function flowCheck(type, reject) {
                var id = $("#leaveId").val();
                $.operate
                $.ajax({
                    url: prefix + "/flowCheck",
                    type: "POST",
                    dataType: "json",
                    data: {
                        "type": type,
                        "id": id,
                        "reject": reject
                    },
                    beforeSend: function () {
                        $.modal.loading("正在处理中，请稍后...");
                    },
                    success: function (result) {
                        $.modal.msgReload(result.msg,modal_status.SUCCESS);
                    }
                })
            }

            $(function () {

                //通过
                $("#through").click(function () {
                    flowCheck(1);
                })

                //驳回
                $("#rejectSubmit").click(function () {
                    flowCheck(2,$("#textareaReject").val())
                })
            })

        </script>
    </body>
</html>